import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import sha256 from 'js-sha256'
import i18n from './lang'
import '@/icons' // icon
import '@/permission' // permission control
import * as filters from '@/filters' // 引入工具类
import VueQuillEditor from 'vue-quill-editor'

// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor /* { default global options } */)

Vue.use(VueQuillEditor /* { default global options } */)

Vue.prototype.$sha256 = sha256
// 注册全局的过滤器
Object.keys(filters).forEach(key => {
  // 注册过滤器
  // Vue.filter(key, filters[key])
  Vue.filter(key, function(key) {
    const dt = new Date(key)
    const y = dt.getFullYear()
    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
    const d = (dt.getDate() + '').padStart(2, '0')
    const hh = (dt.getHours() + '').padStart(2, '0')
    const mm = (dt.getMinutes() + '').padStart(2, '0')
    const ss = (dt.getSeconds() + '').padStart(2, '0')
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  })
})
// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)

// 注册全局的过滤器
// Object.keys(filters).forEach(key => {
//   // 注册过滤器
//   Vue.filter(key, filters[key])
// })
Vue.config.productionTip = false
new Vue({
  el: '#app',
  router,
  i18n,
  store,
  render: h => h(App)
})
